StringFunctions.Character substring function

Extracts a substring from the given string

Format

ANSI-SQL Format:

SUBSTRING ( expression FROM Start [ FOR Length ] )

ODBC Format:

{{ FN SUBSTRING ( expression , Start, Length ) }}

Remarks

The SUBSTRING scalar function extracts a substring from a given string.

The Start argument defines the start position of the substring operation. The Start argument is 1-based, in that the first character is at position 1.

The FOR keyword and associated Length argument are optional and if used defines the maximum number of characters to return. If the FOR keyword and Length argument are omitted, the entire right side of the string is returned.

Both the Start and Length arguments can be any numeric expression.

Example:

Example 1: Return the first three characters of a string.

SUBSTRING( CurrentStateDesc FROM 1 FOR 3 )

Example 2: Return the last three characters of a string.

SUBSTRING( CurrentStateDesc FROM CHAR_LENGTH( CurrentStateDesc ) - 3 )

Example 3: Return the last three characters of a string using ODBC syntax.

{FN SUBSTRING( CurrentStateDesc, CHAR_LENGTH( CurrentStateDesc ) - 3, 3 )}


Disclaimer

ClearSCADA 2017 R3